home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcr / pcr4_4.lha / DIST / threads / USysCalls.c < prev   
C/C++ Source or Header  |  1992-02-18  |  17KB  |  911 lines

  1. /* begincopyright
  2.   Copyright (c) 1988 Xerox Corporation. All rights reserved.
  3.   Use and copying of this software and preparation of derivative works based
  4.   upon this software are permitted. Any distribution of this software or
  5.   derivative works must comply with all applicable United States export
  6.   control laws. This software is made available AS IS, and Xerox Corporation
  7.   makes no warranty about the software, its performance or its conformity to
  8.   any specification. Any person obtaining a copy of this software is requested
  9.   to send their name and post office or electronic mail address to:
  10.     PCR Coordinator
  11.     Xerox PARC
  12.     3333 Coyote Hill Rd.
  13.     Palo Alto, CA 94062
  14.   endcopyright */
  15.  
  16. /*
  17.  * USysCalls.c
  18.  *
  19.  * Demers, December 7, 1990 9:12:40 am PST
  20.  * Hatakeyama, August 18, 1989 2:58:37 pm PDT
  21.  * Boehm, June 7, 1990 1:39:03 pm PDT
  22.  *
  23.  * Unix system calls for threads.
  24.  *
  25.  */
  26.  
  27. #include <xr/ThreadsBackdoor.h>
  28. #include <xr/UIO.h>
  29. #include <xr/UIOPrivate.h>
  30. #include <xr/Errno.h>
  31.  
  32. #include <sys/types.h>
  33. #include <sys/time.h>
  34. #include <sys/file.h>
  35. #include <sys/stat.h>
  36. #include <sys/vfs.h>
  37.  
  38.  
  39. /*
  40.  * The following is the right default for most system calls ...
  41.  */
  42.  
  43. #define iope0 (&(XR_uioArea->uioa_iope[0]))
  44.  
  45.  
  46. static int
  47. XR_DoSysCallInUIOIOP0(iopo, proc)
  48.     XR_IOPOrder iopo;
  49.     void (*proc)(/* XR_IOPOrder order */);
  50. {
  51.     XR_IOPOResult iopoRes;
  52.     int result;
  53.  
  54.     iopoRes = XR_IssueIOPOrder(
  55.     /*iop*/        iope0,
  56.     /*order*/    iopo,
  57.     /*proc*/    proc,
  58.     /*cancel*/    NIL,
  59.     /*abortable*/    FALSE,
  60.     /*timeout*/    XR_WAIT_FOREVER
  61.     );
  62.     if( iopoRes != XR_IOPO_RESULT_OK ) XR_Panic("DoSysCallInUIOIOP0");
  63.     result = iopo->iopo_results[0];
  64.     if( result < 0 ) {
  65.         XR_SetErrno(-result);
  66.         return(-1);
  67.     }
  68.     return result;
  69. }
  70.  
  71.  
  72. /*
  73.  * access(char *path, int mode)
  74.  */
  75.  
  76. void
  77. XR_AccessIOPOrderProc (iopo)
  78.     XR_IOPOrder iopo;
  79. {
  80.     int ans;
  81.  
  82.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_accessPath, NIL);
  83.     if( ans >= 0 ) {
  84.         ans = access(iopo->iopo_accessPath + ans, iopo->iopo_accessMode);
  85.         if( ans < 0 ) ans = (-errno);
  86.     }
  87.     iopo->iopo_results[0] = ans;
  88.     XR_UIONotifyIOPODone(iopo);
  89. }
  90.  
  91. int
  92. XR_Access(path, mode)
  93.     char *path;
  94.     int mode;
  95. {
  96.     struct XR_IOPOrderRep iopoBuf;
  97.  
  98.     iopoBuf.iopo_accessPath = (unsigned) XR_UIOFixPathForIOP(path, iope0);
  99.     iopoBuf.iopo_accessMode = (unsigned) mode;
  100.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_AccessIOPOrderProc );
  101. }
  102.  
  103.  
  104. /*
  105.  * int chmod( char *path, int mode)
  106.  */
  107.  
  108. void
  109. XR_ChModIOPOrderProc (iopo)
  110.     XR_IOPOrder iopo;
  111. {
  112.     int ans;
  113.  
  114.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_chmodPath, NIL);
  115.     if( ans >= 0 ) {
  116.         ans = chmod(iopo->iopo_chmodPath + ans, iopo->iopo_chmodMode);
  117.         if( ans < 0 ) ans = (-errno);
  118.     }
  119.     iopo->iopo_results[0] = ans;
  120.     XR_UIONotifyIOPODone(iopo);
  121. }
  122.  
  123. int
  124. XR_ChMod(path, mode)
  125.     char *path;
  126.     int mode;
  127. {
  128.     struct XR_IOPOrderRep iopoBuf;
  129.  
  130.     iopoBuf.iopo_chmodPath = (unsigned) XR_UIOFixPathForIOP(path, iope0);
  131.     iopoBuf.iopo_chmodMode = (unsigned) mode;
  132.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_ChModIOPOrderProc );
  133. }
  134.  
  135.  
  136. /*
  137.  * int getdomainname(char *name, int namelen)
  138.  */
  139.  
  140. int
  141. XR_GetDomainName(name, nameLen)
  142.     char *name;
  143.     int nameLen;
  144. {
  145.     int ans;
  146.     
  147.     XR_ProtectSysCall(name, nameLen);
  148.     ans = getdomainname(name, nameLen);
  149.     XR_UnprotectSysCall();
  150.     return(ans);
  151. }
  152.  
  153. /*
  154.  * int getdtablesize()
  155.  */
  156.  
  157. int
  158. XR_GetDTableSize ()
  159. {
  160.     return( XR_uioArea->uioa_numFDE );
  161. }
  162.  
  163. /*
  164.  * int getdtablesize1(XR_FDKind kind)
  165.  */
  166.  
  167. int
  168. XR_GetDTableSize1 (kind)
  169.     XR_FDKind kind;
  170. {
  171.     XR_FDE fde, fdeLim;
  172.     int n = 0;
  173.  
  174.     fde = XR_uioArea->uioa_fde;
  175.     fdeLim = XR_UIOFDELimit;
  176.     for( fde = XR_uioArea->uioa_fde; fde < fdeLim; fde++ ) {
  177.     if( fde->fde_fdKind == kind ) n++;
  178.     }
  179.     return( n );
  180. }
  181.  
  182. /*
  183.  * int getnumberoffreefds(XR_FDKind kind)
  184.  */
  185.  
  186.  
  187. int
  188. XR_GetNumberOfFreeFDs (kind)
  189.     XR_FDKind kind;
  190. {
  191.     XR_IOPE iope, iopeLim;
  192.     int freeSlots;
  193.  
  194.     freeSlots = 0;
  195.     iope = XR_uioArea->uioa_iope;
  196.     iopeLim = iope + XR_uioArea->uioa_numIOPE;
  197.     while( iope < iopeLim ) {
  198.         if( iope->iope_uioFDKind == kind ) freeSlots += iope->iope_uioFreeSlots;
  199.         iope++;
  200.     }
  201.     return freeSlots;
  202. }
  203.  
  204.  
  205. /*
  206.  * int getgid()
  207.  */
  208.  
  209. int
  210. XR_GetGID ()
  211. {
  212.     return( getgid() );
  213. }
  214.  
  215. /*
  216.  * int getegid()
  217.  */
  218.  
  219. int
  220. XR_GetEGID ()
  221. {
  222.     return( getegid() );
  223. }
  224.  
  225. /*
  226.  * int getgroups(int gidsetlen, int *gidset)
  227.  */
  228.  
  229. int
  230. XR_GetGroups(gidSetLen, gidSet)
  231.     int gidSetLen;
  232.     int *gidSet;
  233. {
  234.     int ans;
  235.     
  236.     XR_ProtectSysCall(gidSet, gidSetLen * sizeof(int));
  237.     ans = getgroups(gidSetLen, gidSet);
  238.     XR_UnprotectSysCall();
  239.     return(ans);
  240. }
  241.  
  242. /*
  243.  * int gethostid()
  244.  */
  245.  
  246. int
  247. XR_GetHostID(/* */)
  248. {
  249.     return( gethostid() );
  250. }
  251.  
  252. /*
  253.  * int gethostname(char *name, int namelen)
  254.  */
  255.  
  256. int
  257. XR_GetHostName(name, nameLen)
  258.     char *name;
  259.     int nameLen;
  260. {
  261.     int ans;
  262.     
  263.     XR_ProtectSysCall(name, nameLen);
  264.     ans = gethostname(name, nameLen);
  265.     XR_UnprotectSysCall();
  266.     return(ans);
  267. }
  268.  
  269.  
  270. /*
  271.  * int getpagesize()
  272.  *
  273.  * (this is implemented in ThreadsSharemMem.c)
  274.  *
  275. int
  276. XR_GetPageSize()
  277. {
  278.     return( getpagesize() );
  279. }
  280.  *
  281.  */
  282.  
  283.  
  284. /*
  285.  * int getpgrp(int pid)
  286.  */
  287.  
  288. int
  289. XR_GetPGrp(pid)
  290.     int pid;
  291. {
  292.     return( getpgrp(pid) );
  293. }
  294.  
  295.  
  296. /*
  297.  * int getpid()
  298.  */
  299.  
  300. int
  301. XR_GetPID()
  302. {
  303.     return( XR_sysArea != NIL
  304.     ? XR_sysArea->sa_vpe[0].vpe_pid
  305.     : -1 );
  306. }
  307.  
  308.  
  309. /*
  310.  * int getppid()
  311.  */
  312.  
  313. int
  314. XR_GetPPID()
  315. {
  316.     return( XR_sysArea != NIL
  317.     ? XR_sysArea->sa_dbpid
  318.     : -1 );
  319. }
  320.  
  321.  
  322. /*
  323.  * int gettimeofday(struct timeval *tp, struct timezone *tzp)
  324.  */
  325.  
  326. int
  327. XR_GetTimeOfDay(tp, tzp)
  328.     struct timeval *tp;
  329.     struct timezone *tzp;
  330. {
  331.     struct timeval myT;
  332.     struct timezone myTZ;
  333.     int ans;
  334.     
  335.     ans = gettimeofday(&myT, &myTZ);
  336.     if (tp != NIL) {
  337.         *tp = myT;
  338.     }
  339.     if (tzp != NIL) {
  340.         *tzp = myTZ;
  341.     }
  342.     return(ans);
  343. }
  344.  
  345. /*
  346.  * int getuid()
  347.  */
  348.  
  349. int
  350. XR_GetUID()
  351. {
  352.     return( getuid() );
  353. }
  354.  
  355.  
  356. /*
  357.  * int geteuid()
  358.  */
  359.  
  360. int
  361. XR_GetEUID()
  362. {
  363.     return( geteuid() );
  364. }
  365.  
  366.  
  367. /*
  368.  * int kill(int pid, int sig)
  369.  */
  370.  
  371. int
  372. XR_Kill(pid, sig)
  373.     int pid;
  374.     int sig;
  375. {
  376.     return( kill(pid, sig) );
  377. }
  378.  
  379.  
  380. /*
  381.  * int killpg(int pgrp, int sig)
  382.  */
  383.  
  384. int
  385. XR_KillPG(pgrp, sig)
  386.     int pgrp;
  387.     int sig;
  388. {
  389.     return( killpg(pgrp, sig) );
  390. }
  391.  
  392.  
  393. /*
  394.  * int link(char *name1, char *name2)
  395.  * (name1 exists, name2 is created)
  396.  */
  397.  
  398. void
  399. XR_LinkIOPOrderProc (iopo)
  400.     XR_IOPOrder iopo;
  401. {
  402.     int ans;
  403.  
  404.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_linkName1, iopo->iopo_linkName2);
  405.     if( ans >= 0 ) {
  406.         ans = link(iopo->iopo_linkName1+ans, iopo->iopo_linkName2+ans);
  407.         if( ans < 0 ) ans = (-errno);
  408.     }
  409.     iopo->iopo_results[0] = ans;
  410.     XR_UIONotifyIOPODone(iopo);
  411. }
  412.  
  413.  
  414. int
  415. XR_Link(name1, name2)
  416.     char *name1;
  417.     char *name2;
  418. {
  419.     struct XR_IOPOrderRep iopoBuf;
  420.  
  421.     iopoBuf.iopo_linkName1 = (unsigned) XR_UIOFixPathForIOP(name1, iope0);
  422.     iopoBuf.iopo_linkName2 = (unsigned) XR_UIOFixPathForIOP(name2, iope0);
  423.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_LinkIOPOrderProc );
  424. }
  425.  
  426. /*
  427.  * int mincore(char *addr, int len, char *vec)
  428.  */
  429.  
  430. int
  431. XR_MInCore(addr, len, vec)
  432.     char *addr;
  433.     int len;
  434.     char *vec;
  435. {
  436.     int ps = XR_GetPageSize();
  437.     int ans;
  438.     int sz = (len + ps-1)/ps;
  439.     
  440.     XR_ProtectSysCall(vec, sz);
  441.     ans = mincore(addr, len, vec);
  442.     XR_UnprotectSysCall();
  443.     return(ans);
  444. }
  445.  
  446. /*
  447.  * int mkdir(char *path, int mode)
  448.  */
  449.  
  450. void
  451. XR_MkDirIOPOrderProc (iopo)
  452.     XR_IOPOrder iopo;
  453. {
  454.     int ans;
  455.  
  456.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_mkdirPath, NIL);
  457.     if( ans >= 0 ) {
  458.         ans = mkdir(iopo->iopo_mkdirPath + ans, iopo->iopo_mkdirMode);
  459.         if( ans < 0 ) ans = (-errno);
  460.     }
  461.     iopo->iopo_results[0] = ans;
  462.     XR_UIONotifyIOPODone(iopo);
  463. }
  464.  
  465. int
  466. XR_MkDir(path, mode)
  467.     char *path;
  468.     int mode;
  469. {
  470.     struct XR_IOPOrderRep iopoBuf;
  471.  
  472.     iopoBuf.iopo_mkdirPath = (unsigned) XR_UIOFixPathForIOP(path, iope0);
  473.     iopoBuf.iopo_mkdirMode = (unsigned) mode;
  474.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_MkDirIOPOrderProc );
  475. }
  476.  
  477.  
  478.  
  479. /*
  480.  * int mknod(char *name, int mode, int dev)
  481.  */
  482.  
  483. void
  484. XR_MkNodIOPOrderProc (iopo)
  485.     XR_IOPOrder iopo;
  486. {
  487.     int ans;
  488.  
  489.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_mknodName, NIL);
  490.     if( ans >= 0 ) {
  491.         ans = mknod(iopo->iopo_mknodName + ans,
  492.                 iopo->iopo_mknodMode, iopo->iopo_mknodDev);
  493.         if( ans < 0 ) ans = (-errno);
  494.     }
  495.     iopo->iopo_results[0] = ans;
  496.     XR_UIONotifyIOPODone(iopo);
  497. }
  498.  
  499. int
  500. XR_MkNod(name, mode, dev)
  501.     char *name;
  502.     int mode;
  503.     int dev;
  504. {
  505.     struct XR_IOPOrderRep iopoBuf;
  506.  
  507.     iopoBuf.iopo_mknodName = (unsigned) XR_UIOFixPathForIOP(name, iope0);
  508.     iopoBuf.iopo_mknodMode = (unsigned) mode;
  509.     iopoBuf.iopo_mknodDev = (unsigned) dev;
  510.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_MkNodIOPOrderProc );
  511. }
  512.  
  513.  
  514. /*
  515.  * int profil(char *buf, int bufSize, int offset, int scale)
  516.  */
  517.  
  518. void
  519. XR_ProfilVPOrderProc (vpo)
  520.     XR_VPOrder vpo;
  521. {
  522.     if (XR_OverlapsVDProtected(vpo->vpo_profBuf, vpo->vpo_profBufSize)) {
  523.         XR_ConsoleMsg("%? Profile request has heap buffer - ignored\n");
  524.     } else {
  525.         (void)profil(vpo->vpo_profBuf, vpo->vpo_profBufSize,
  526.                  vpo->vpo_profOffset, vpo->vpo_profScale);
  527.     }
  528. }
  529.  
  530.  
  531. void
  532. XR_ProfilIOPOrderProc (iopo)
  533.     XR_IOPOrder iopo;
  534. {
  535.     XR_VPOrder vpo = &(XR_uioArea->uioa_profVPOrderBuf);
  536.  
  537.     vpo->vpo_profBuf = iopo->iopo_profBuf;
  538.     vpo->vpo_profBufSize = iopo->iopo_profBufSize;
  539.     vpo->vpo_profOffset = iopo->iopo_profOffset;
  540.     vpo->vpo_profScale = iopo->iopo_profScale;
  541.     XR_IssueVPOrder(
  542.     /*order*/    vpo,
  543.     /*proc*/    XR_ProfilVPOrderProc,
  544.     /*stop*/    FALSE
  545.     );
  546.     XR_NotifyIOPODone(iopo);
  547. }
  548.  
  549.  
  550. int
  551. XR_Profil(buf, bufSize, offset, scale)
  552.     char *buf;
  553.     int bufSize;
  554.     int offset;
  555.     int scale;
  556. {
  557.     struct XR_IOPOrderRep iopOrderBuf;
  558.     XR_IOPOResult res;
  559.  
  560.     XR_InitIOPOrder(&iopOrderBuf);
  561.     iopOrderBuf.iopo_profBuf = ((unsigned)(buf));
  562.     iopOrderBuf.iopo_profBufSize = ((unsigned)(bufSize));
  563.     iopOrderBuf.iopo_profOffset = ((unsigned)(offset));
  564.     iopOrderBuf.iopo_profScale = ((unsigned)(scale));
  565.     res = XR_IssueIOPOrder(
  566.     /*iop*/        XR_uioArea->uioa_iope,
  567.     /*order*/    &iopOrderBuf,
  568.     /*proc*/    XR_ProfilIOPOrderProc,
  569.     /*cancel*/    NIL,
  570.     /*abortable*/    FALSE,
  571.     /*timeout*/    XR_WAIT_FOREVER
  572.     );
  573.     if( res != XR_IOPO_RESULT_OK ) XR_Panic("Profil");
  574.     return( 0 );
  575. }
  576.  
  577. /*
  578.  * int readlink(char *path, char *buf, int bufsiz)
  579.  */
  580.  
  581. void
  582. XR_ReadLinkIOPOrderProc (iopo)
  583.     XR_IOPOrder iopo;
  584. {
  585.     int ans;
  586.  
  587.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_readlinkPath, NIL);
  588.     if( ans >= 0 ) {
  589.         ans = readlink(iopo->iopo_readlinkPath + ans,
  590.                 iopo->iopo_readlinkBuf, iopo->iopo_readlinkBufsiz);
  591.         if( ans < 0 ) ans = (-errno);
  592.     }
  593.     iopo->iopo_results[0] = ans;
  594.     XR_UIONotifyIOPODone(iopo);
  595. }
  596.  
  597. int
  598. XR_ReadLink(path, buf, bufsiz)
  599.     char *path;
  600.     char *buf;
  601.     int bufsiz;
  602. {
  603.     struct XR_IOPOrderRep iopoBuf;
  604.  
  605.     iopoBuf.iopo_readlinkPath = (unsigned) XR_UIOFixPathForIOP(path, iope0);
  606.     iopoBuf.iopo_readlinkBuf = (unsigned) buf;
  607.     iopoBuf.iopo_readlinkBufsiz = (unsigned) bufsiz;
  608.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_ReadLinkIOPOrderProc );
  609. }
  610.  
  611.  
  612. /*
  613.  * int rename(char *from, char *to)
  614.  */
  615.  
  616. void
  617. XR_RenameIOPOrderProc (iopo)
  618.     XR_IOPOrder iopo;
  619. {
  620.     int ans;
  621.  
  622.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_renameFrom, iopo->iopo_renameTo);
  623.     if( ans >= 0 ) {
  624.         ans = rename(iopo->iopo_renameFrom+ans, iopo->iopo_renameTo+ans);
  625.         if( ans < 0 ) ans = (-errno);
  626.     }
  627.     iopo->iopo_results[0] = ans;
  628.     XR_UIONotifyIOPODone(iopo);
  629. }
  630.  
  631.  
  632. int
  633. XR_Rename(from, to)
  634.     char *from;
  635.     char *to;
  636. {
  637.     struct XR_IOPOrderRep iopoBuf;
  638.  
  639.     iopoBuf.iopo_renameFrom = (unsigned) XR_UIOFixPathForIOP(from, iope0);
  640.     iopoBuf.iopo_renameTo = (unsigned) XR_UIOFixPathForIOP(to, iope0);
  641.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_RenameIOPOrderProc );
  642. }
  643.  
  644.  
  645. /*
  646.  * int rmdir(char *name)
  647.  */
  648.  
  649. void
  650. XR_RmDirIOPOrderProc (iopo)
  651.     XR_IOPOrder iopo;
  652. {
  653.     int ans;
  654.  
  655.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_rmdirName, NIL);
  656.     if( ans >= 0 ) {
  657.         ans = rmdir(iopo->iopo_rmdirName + ans);
  658.         if( ans < 0 ) ans = (-errno);
  659.     }
  660.     iopo->iopo_results[0] = ans;
  661.     XR_UIONotifyIOPODone(iopo);
  662. }
  663.  
  664. int
  665. XR_RmDir(name)
  666.     char *name;
  667. {
  668.     struct XR_IOPOrderRep iopoBuf;
  669.  
  670.     iopoBuf.iopo_rmdirName = (unsigned) XR_UIOFixPathForIOP(name, iope0);
  671.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_RmDirIOPOrderProc );
  672. }
  673.  
  674. /*
  675.  * int stat(char *path, struct stat *buf)
  676.  */
  677.  
  678. void
  679. XR_StatIOPOrderProc (iopo)
  680.     XR_IOPOrder iopo;
  681. {
  682.     int ans;
  683.  
  684.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_statPath, NIL);
  685.     if( ans >= 0 ) {
  686.         ans = stat(iopo->iopo_statPath + ans, iopo->iopo_statBuf);
  687.         if( ans < 0 ) ans = (-errno);
  688.     }
  689.     iopo->iopo_results[0] = ans;
  690.     XR_UIONotifyIOPODone(iopo);
  691. }
  692.  
  693. int
  694. XR_Stat(path, buf)
  695.     char *path;
  696.     struct stat *buf;
  697. {
  698.     struct XR_IOPOrderRep iopoBuf;
  699.  
  700.     iopoBuf.iopo_statPath = (unsigned) XR_UIOFixPathForIOP(path, iope0);
  701.     iopoBuf.iopo_statBuf = (unsigned) buf;
  702.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_StatIOPOrderProc );
  703. }
  704.  
  705.  
  706. /*
  707.  * int lstat(char *path, struct stat *buf)
  708.  */
  709.  
  710. void
  711. XR_LStatIOPOrderProc (iopo)
  712.     XR_IOPOrder iopo;
  713. {
  714.     int ans;
  715.  
  716.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_lstatPath, NIL);
  717.     if( ans >= 0 ) {
  718.         ans = lstat(iopo->iopo_lstatPath + ans, iopo->iopo_lstatBuf);
  719.         if( ans < 0 ) ans = (-errno);
  720.     }
  721.     iopo->iopo_results[0] = ans;
  722.     XR_UIONotifyIOPODone(iopo);
  723. }
  724.  
  725. int
  726. XR_LStat(path, buf)
  727.     char *path;
  728.     struct stat *buf;
  729. {
  730.     struct XR_IOPOrderRep iopoBuf;
  731.  
  732.     iopoBuf.iopo_lstatPath = (unsigned) XR_UIOFixPathForIOP(path, iope0);
  733.     iopoBuf.iopo_lstatBuf = (unsigned) buf;
  734.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_LStatIOPOrderProc );
  735. }
  736.  
  737.  
  738.  
  739. /*
  740.  * int statfs(char *path, struct statfs *buf)
  741.  */
  742.  
  743. void
  744. XR_StatFSIOPOrderProc (iopo)
  745.     XR_IOPOrder iopo;
  746. {
  747.     int ans;
  748.  
  749.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_statfsPath, NIL);
  750.     if( ans >= 0 ) {
  751.         ans = statfs(iopo->iopo_statfsPath + ans, iopo->iopo_statfsBuf);
  752.         if( ans < 0 ) ans = (-errno);
  753.     }
  754.     iopo->iopo_results[0] = ans;
  755.     XR_UIONotifyIOPODone(iopo);
  756. }
  757.  
  758. int
  759. XR_StatFS(path, buf)
  760.     char *path;
  761.     struct stat *buf;
  762. {
  763.     struct XR_IOPOrderRep iopoBuf;
  764.  
  765.     iopoBuf.iopo_statfsPath = (unsigned) XR_UIOFixPathForIOP(path, iope0);
  766.     iopoBuf.iopo_statfsBuf = (unsigned) buf;
  767.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_StatFSIOPOrderProc );
  768. }
  769.  
  770.  
  771. /*
  772.  * int symlink(char *name1, char *name2)
  773.  * (name1 exists, name2 is created)
  774.  */
  775.  
  776. void
  777. XR_SymLinkIOPOrderProc (iopo)
  778.     XR_IOPOrder iopo;
  779. {
  780.     int ans;
  781.  
  782.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_symlinkName2, NIL);
  783.     if( ans >= 0 ) {
  784.         ans = symlink(iopo->iopo_symlinkName1,
  785.                 iopo->iopo_symlinkName2+ans);
  786.         if( ans < 0 ) ans = (-errno);
  787.     }
  788.     iopo->iopo_results[0] = ans;
  789.     XR_UIONotifyIOPODone(iopo);
  790. }
  791.  
  792.  
  793. int
  794. XR_SymLink(name1, name2)
  795.     char *name1;
  796.     char *name2;
  797. {
  798.     struct XR_IOPOrderRep iopoBuf;
  799.  
  800.     iopoBuf.iopo_symlinkName1 = (unsigned) XR_UIOFixPathForIOP(name1, iope0);
  801.     iopoBuf.iopo_symlinkName2 = (unsigned) XR_UIOFixPathForIOP(name2, iope0);
  802.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_SymLinkIOPOrderProc );
  803. }
  804.  
  805.  
  806. /*
  807.  * int sync()
  808.  */
  809.  
  810. int
  811. XR_Sync()
  812. {
  813.     return( sync() );
  814. }
  815.  
  816.  
  817. /*
  818.  * int truncate(char *path, unsigned length)
  819.  */
  820.  
  821. void
  822. XR_TruncateIOPOrderProc (iopo)
  823.     XR_IOPOrder iopo;
  824. {
  825.     int ans;
  826.  
  827.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_truncatePath, NIL);
  828.     if( ans >= 0 ) {
  829.         ans = truncate(iopo->iopo_truncatePath + ans,
  830.                 iopo->iopo_truncateLength);
  831.         if( ans < 0 ) ans = (-errno);
  832.     }
  833.     iopo->iopo_results[0] = ans;
  834.     XR_UIONotifyIOPODone(iopo);
  835. }
  836.  
  837. int
  838. XR_Truncate(path, length)
  839.     char *path;
  840.     unsigned length;
  841. {
  842.     struct XR_IOPOrderRep iopoBuf;
  843.  
  844.     iopoBuf.iopo_truncatePath = (unsigned) XR_UIOFixPathForIOP(path, iope0);
  845.     iopoBuf.iopo_truncateLength = (unsigned) length;
  846.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_TruncateIOPOrderProc );
  847. }
  848.  
  849.  
  850. /*
  851.  * int unlink(char *path)
  852.  */
  853.  
  854. void
  855. XR_UnlinkIOPOrderProc (iopo)
  856.     XR_IOPOrder iopo;
  857. {
  858.     int ans;
  859.  
  860.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_unlinkPath, NIL);
  861.     if( ans >= 0 ) {
  862.         ans = unlink(iopo->iopo_unlinkPath + ans);
  863.         if( ans < 0 ) ans = (-errno);
  864.     }
  865.     iopo->iopo_results[0] = ans;
  866.     XR_UIONotifyIOPODone(iopo);
  867. }
  868.  
  869. int
  870. XR_Unlink(path)
  871.     char *path;
  872. {
  873.     struct XR_IOPOrderRep iopoBuf;
  874.  
  875.     iopoBuf.iopo_unlinkPath = (unsigned) XR_UIOFixPathForIOP(path, iope0);
  876.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_UnlinkIOPOrderProc );
  877. }
  878.  
  879.  
  880. /*
  881.  * int utimes(char *file, struct timeval *tvp)
  882.  */
  883.  
  884. void
  885. XR_UTimesIOPOrderProc (iopo)
  886.     XR_IOPOrder iopo;
  887. {
  888.     int ans;
  889.  
  890.     ans = XR_UIOIOPChDirForPaths(iopo->iopo_utimesFile, NIL);
  891.     if( ans >= 0 ) {
  892.         ans = utimes(iopo->iopo_utimesFile + ans, iopo->iopo_utimesTVP);
  893.         if( ans < 0 ) ans = (-errno);
  894.     }
  895.     iopo->iopo_results[0] = ans;
  896.     XR_UIONotifyIOPODone(iopo);
  897. }
  898.  
  899. int
  900. XR_UTimes(file, tvp)
  901.     char *file;
  902.     struct timeval *tvp;
  903. {
  904.     struct XR_IOPOrderRep iopoBuf;
  905.  
  906.     iopoBuf.iopo_utimesFile = (unsigned) XR_UIOFixPathForIOP(file, iope0);
  907.     iopoBuf.iopo_utimesTVP = (unsigned) tvp;
  908.     return XR_DoSysCallInUIOIOP0( &iopoBuf, XR_UTimesIOPOrderProc );
  909. }
  910.  
  911.